package com.coin900.coin.cmd.address;

import com.coin900.coin.cmd.CmdSign;
import com.coin900.coin.code.CmdCode;
import com.google.gson.Gson;
import com.coin900.coin.cmd.ACmd;
import com.coin900.coin.persist.sbi.SbiCityVO;
import com.coin900.coin.persist.sbi.SbiProvinceVO;
import com.coin900.coin.service.sbi.ISbiCityService;
import com.coin900.coin.service.sbi.ISbiProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 城市
 *
 * @author shui
 * @create 2017-11-28
 **/
@Controller
public class CityListCmd extends ACmd {

    @Override
    public CmdSign execute(HttpServletRequest request, CmdSign sign) throws Exception {
        CmdSign respSign = new CmdSign(sign);
        Map<String, Object> params = new HashMap<>();
        params.put("dataStatus", 1);
        if(sign.getParams()!=null){
            params.putAll(sign.getParams());
        }
        List<SbiCityVO> cityVOS = this.cityService.loadSbiCity(params);
        String source = new Gson().toJson(cityVOS);
        respSign.setSource(source);
        return respSign;
    }



    @Autowired
    private ISbiCityService cityService;

    @Override
    public String getCmdCode() {
        return CmdCode.CITY_LIST;
    }
}
